package com.biscuit.page.basicservice.utils;

import java.util.regex.Pattern;

/**
 * @author biscuit
 * @createTime 2024/5/23 15:45
 */
public class RegexUtil {

    /**
     * 校验邮箱是否合法
     */
    public static boolean validateEmail(String email) {
        Pattern pattern = Pattern.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
        return pattern.matcher(email).matches();
    }

    /**
     * 校验手机号是否合法
     */
    public static boolean validateMobile(String mobile) {
        Pattern pattern = Pattern.compile("^1[3-9]\\d{9}$");
        return pattern.matcher(mobile).matches();
    }

}
